home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / MEMCCPY.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  30 lines

  1.  
  2.     File   : memccpy.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 25 May 1984
  5.     Defines: memccpy()
  6.  
  7.     memccpy(dst, src, chr, len)
  8.     copies bytes from src to dst until either len bytes have been moved
  9.     or a byte equal to chr has been moved.  In the former case it gives
  10.     NullS as the value, in the latter a pointer to just after the place
  11.     where "chr" was moved to in dst.  Note that copying stops after the
  12.     first instance of "chr", and that remaining characters in "dst" are
  13.     not changed in any way, no NUL being inserted or anything.
  14.  
  15.     See the "Character Comparison" section in the READ-ME file.
  16. */
  17.  
  18. #include "strings.h"
  19.  
  20. char *memccpy(dst, src, chr, len)
  21.     register char *dst, *src;
  22.     register int chr;           /* should be char */
  23.     register int len;
  24.     {
  25.         while (--len >= 0)
  26.             if ((*dst++ = *src++) == chr) return dst;
  27.         return NullS;
  28.     }
  29.  
  30.